<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>生产备注</title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" type="text/css" href="${basePath}/static/css/production.css?v=${version}"/>
</head>
<body>
<div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
    <input type="hidden" value="${scorderId}" id="hiddenScOrderId">
        <c:if test="${scProductOrderStatus != 'ZZSC_STATE_SCPROORDER_CODE1' && scProductOrderStatus != 'ZZSC_STATE_SCPROORDER_CODE2'
        && scProductOrderStatus != 'ZZSC_STATE_SCPROORDER_CODE3' && scProductOrderStatus != 'ZZSC_STATE_SCPROORDER_CODE4'
         && scProductOrderStatus != 'ZZSC_STATE_SCPROORDER_CODE5'}">
    <div class="finan-panel">
        <div class="finan-tit">
            <b>生产备注</b>
        </div>
        <div class="panel-main">
            <div class="production-list">
                <span class="required">备注节点</span>
                <select class="select-style" name="remarksNode" id="remarksNode">
                    <option value="">请选择</option>
                    <c:forEach var="remarksnode" items="${productNodes}">
                        <option value="${remarksnode.id}">${remarksnode.name}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="production-list">
                <span class="form-label required">备注记录</span>
                <textarea class="textarea-style" rows="3" id="remark" name="remark" placeholder="500字以内" ></textarea>
            </div>
                <ul class="data-warp">
                    <li>
                        <a href="javascript:void(0)" class="upload-button" id="upload"></a>
                        <input class="layui-upload-file" type="file" name="file" multiple="" id="annexUpload" data-type="product" data-fileid="${scorderId}">
                        <p>上传附件</p>
                    </li>
                </ul>
            <div class="production-list">
                <button class="layui-btn" onclick="saveremarkByDetail()">保存</button>
            </div>
        </div>
    </div>
        </c:if>
    <div class="finan-panel" style="height: 400px;">
        <div class="finan-tit">
            <b>生产备注记录</b>
        </div>
        <div class="panel-main">
            <div class="tab-content-main">
                <div class="record-warp">
                    <select class="select-style" name="seachNode" onchange="reloadTable()">
                        <option value="">全部</option>
                        <c:forEach var="allRemarksNode" items="${allRemarksNodeList}">
                            <option value="${allRemarksNode.id}">${allRemarksNode.name}</option>
                        </c:forEach>
                    </select>
                </div>
                <div class="dataTables_wrapper no-footer">
                    <!--表格 end-->
                    <table class="cell-border crm-table columnsHidden" id="remarksNodeTable">
                        <thead>
                        <tr>
                            <th>项目类型</th>
                            <th>生产节点/操作</th>
                            <th>操作时间</th>
                            <th>操作人</th>
                            <th>备注内容</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!--生产节点备注记录 end-->
    </div>
</div>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script src="${rootUrl}/static/js/zzsc/common/files/annex.js?v=${version}" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    DGG.loading('close');
    var tableReload;
    $(document).ready(function () {
        //初始化dataTable列表
        tableReload = $('#remarksNodeTable').dataTableExtend({
            "ajax": {
                "url": "${basePath}/zzsc/inprocess/query_product_operating_list.do?scProductOrderId=${scorderId}",
                "type": "post"
            },
            "fnServerParams": function (aoData) {
                //搜索条件
                aoData.optstate = $('[name="seachNode"]').val();
            },
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 1,//左侧锁定2列
                "rightColumns": 0//右侧锁定1列
            },
            pageLength: 10,
            "aoColumns": [
                {
                    "orderable": false,
                    "data": "flowType"
                },
                {
                    "orderable": false,
                    "data": "nodeName"
                },{
                    "orderable": false,
                    "data": "createTime"
                }, {
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        var remark = row.createrName+"<br/>"+row.createrOrgName;
                        return remark;
                    }
                }, {
                    "orderable": false,
                    "data": "remark",
                    "render": function (data, type, row, meta) {
                        var remark = (null != row.remark && "" != row.remark) ? row.remark : "-";
                        return "<div title='" + remark + "' class='line2' style=\"max-width:500px;word-wrap:break-word\">" + remark + "</div>";
                    }
                }]
        });
        areaLength($('#remark'),500)
    });

    function reloadTable() {
        $('#remarksNodeTable').dataTableExtend("reloadFalse");
    }
    function saveremarkByDetail() {
        var productOrderId = $('#hiddenScOrderId').val();
        var nodeId = $('[name="remarksNode"]').val();
        var nodeName = $('[name="remarksNode"]').find("option:selected").text();
        var remark = $('[name="remark"]').val();
       if (checkIsEmpty(nodeId)){
           DGG.Warning("请选择备注节点!");
           return;
       }
       if (checkIsEmpty(remark)){
           DGG.Warning("备注记录不能为空 !");
           return;
       }
        DGG.Confire("确定保存备注吗？", "生产备注", function () {
            DGG.loading();
            $.ajax({
                type: 'POST',
                data: {
                    nodeId: nodeId,
                    nodeName: nodeName,
                    remark: remark,
                    productOrderId: productOrderId
                },
                url: sysInfo.basePath + '/zzsc/inprocess/save_product_operating_by_detail.do',
                dataType: 'JSON',
                success: function (data) {
                    DGG.loading('close');
                    if (data.code != 0) {
                        DGG.Errors(data.msg);
                    } else {
                        DGG.Succeed("操作成功!");
                        window.location.reload();
                    }
                },
                error: function () {
                    DGG.Errors('保存失败，请联系管理员！');
                }
            })
        })
    }
</script>
</body>
</html>
